	<CFQUERY NAME="GetCalendarData" DATASOURCE="#table_dsn#" MAXROWS=1>
		SELECT *
		FROM #eform.tablename#
		WHERE
			(PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#') AND
			(#GetForm.CALENDARFIELD# = '#url.alttaskid#')
	</CFQUERY>

	<CFIF GetCalendarData.RecordCount>
		<!--- edit the record --->
		<!--- get the values of the indexed fields --->
		<CFSET sUFValue = "">
		<CFLOOP  INDEX="x" FROM="1" TO="5">
			<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
				<CFSET sUFValue = sUFValue & "&" & lcase(evaluate("GetForm.PK_FIELD" & x)) & "=" & evaluate("GetCalendarData." & evaluate("GetForm.PK_FIELD" & x))>
			</CFIF>
		</CFLOOP>

		<CFSET lEdit = True>
		<CFIF len(trim(GetCalendarData.ROUTEID)) NEQ 0 OR
			    lcase(GetCalendarData.APPROVED) EQ "y" OR
			    lcase(GetCalendarData.APPROVED) EQ "C">
			<CFSET lEdit = False>
		</CFIF>

		<!--- re-route --->
		<CFIF lcase(accessEdit) EQ "y" AND lEdit>
			<CFLOCATION URL="#eform.sender##sUFValue#&edit=" ADDTOKEN="No">
		<CFELSE>
			<CFLOCATION URL="#eform.sender##sUFValue#&view=" ADDTOKEN="No">
		</CFIF>
	<CFELSE>
		<!--- add a new record --->
		<CFPARAM NAME="Form.Add" DEFAULT="">
		<CFINCLUDE TEMPLATE="editform.cfm">
	</CFIF>
